<?php

use App\Http\Controllers\DistrictController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Illuminate\Routing\Router;
use App\Http\Controllers\ParishController;
use App\Http\Controllers\OrganizationController;
use App\Http\Controllers\Home\DioceseController as HomeDioController;
use App\Http\Controllers\Home\ParishController as HomeParishController;
use App\Http\Controllers\Home\OrganizationController as HomeOrganizationController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group([
    'namespace' => 'App\\Http\\Controllers',
], function (Router $router) {
    //不用授权的
    $router->get('district',[DistrictController::class,'getlist']);
    $router->get('diocese/getlist',[\App\Http\Controllers\DioceseController::class,'getlist']);
    $router->get('organization-type/getlist',[\App\Http\Controllers\OrganizationTypeController::class,'getlist']);
    $router->middleware(['auth:sanctum', 'mojito.permission'])->group(function ($router) {
        $router->get('/parish/getlist',[ParishController::class,'getlist'])->name('parish.getlist');
        $router->apiResources([
            'diocese' => 'DioceseController',
            'parish'=>'ParishController',
            'organization' => 'OrganizationController',
            'organization-type' => 'OrganizationTypeController'
        ]);
        $router->get('/organization/{organization}/edit',[OrganizationController::class,'edit']);
        $router->get('/parish/{parish}/edit',[ParishController::class,'edit']);
//            $router->get('role/{id}/permissions', 'RoleController@permissions')->name('role.permissions');
//            $router->put('role/{id}/permissions', 'RoleController@assignPermissions')->name('role.assign-permissions');
    });

    //home
    $router->get('getDioceseHomeList',[HomeDioController::class,'getlist']);
    $router->get('getDioceseListHasParish',[HomeDioController::class,'getListHasParish']);
    $router->get('getParishHomeList',[HomeParishController::class,'getlist']);
    $router->get('home/organization/all',[HomeOrganizationController::class,'all']);

});

// $all = Route::getRoutes();
// $curr = Route::current();
// dump($curr);
// dump($all);
